<html>
<!--
  Copyright 2013 The Chromium Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.
-->
<head>
  <title>PNaCl Request Header Test</title>
</head>
<body>
<script type="text/javascript" src="../load_util.js"></script>
<script>
function create(manifest_urls, index) {
  if (manifest_urls.length == index) {
    load_util.shutdown(index + " test(s) passed.", true);
    return;
  }
  var embed = document.createElement("embed");
  if (manifest_urls[index].cors) {
    embed.src = load_util.crossOriginURL(manifest_urls[index].url);
  } else {
    embed.src = manifest_urls[index].url;
  }
  embed.type = "application/x-pnacl";

  embed.addEventListener("error", function(evt) {
    // Since we only inspect the *request* header, we bail out with an
    // error before completing the pexe load.
    load_util.report(
        {type: "Log", message: "Expected error: " + embed.lastError});
    create(manifest_urls, index + 1);
  }, true);

  document.body.appendChild(embed);
}

var tests = [{url: "pnacl_request_header.nmf", cors: false},
             {url: "pnacl_cors_header.nmf", cors: true}];
create(tests, 0);
</script>
</body>
</html>
